package jike.demo82;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import java.util.concurrent.TimeUnit;

/**
 * @author oyz
 * @version 1.0.4
 * @description: 使用Guava工具包缓存
 * @date 2023/7/24 21:47
 */
public class CacheDemo {




    public static void main(String[] args) {
        Cache<Object, Object> build = CacheBuilder.newBuilder()
                .initialCapacity(100)
                .maximumSize(1000)
                .expireAfterWrite(10, TimeUnit.MINUTES)
                .build();
        build.put("key","value");
        System.out.println(build.getIfPresent("key"));
    }


}
